package com.langsheng.lsintell.utils;

import java.io.File;

import android.content.Context;
import android.os.Environment;

import com.langsheng.lsintell.R;

public class LSStaticPath {

    public static String DEFAULT_FOLDER; // 根文件夹
    public static String TEMP_FOLDER; // 下载中的临时文件存放文件夹
//    public static String DOC_FOLDER; // 文档中心文件夹
//    public static String RECORDER_FOLDER; // 发送的语音存放文件夹
//    public static String PIC_FOLDER; // 用户头像保存的文件夹
//    public static String ATTACH_FOLDER; // 附件下载的文件夹
//    public static String PHOTO_FOLDER; // 发送的拍照生成的文件存放的文件夹
//    public static String RECORDER_VIDEO_FOLDER;// 录制视频文件夹
//    public static String IMAGE_FOLDER; // 其他图片存放的文件夹
//    public static String UPGRADE_FOLDER; //升级程序存放的文件夹

    private static LSStaticPath instance = new LSStaticPath();

    private LSStaticPath() {
    }

    public static LSStaticPath getInstance() {
        return instance;
    }

    public void init(Context context) {
        String sdcard = Environment.getExternalStorageDirectory() + "/";

        DEFAULT_FOLDER = sdcard + context.getResources().getString(R.string.app_name) + "/";
        createFolder(DEFAULT_FOLDER);

        TEMP_FOLDER = sdcard + context.getResources().getString(R.string.im_temp_folder) + "/";
        createFolder(TEMP_FOLDER);

//        DOC_FOLDER = DEFAULT_FOLDER + context.getResources().getString(R.string.im_doc_folder) + "/";
//        createFolder(DOC_FOLDER);
//
//        RECORDER_FOLDER = DEFAULT_FOLDER + context.getResources().getString(R.string.im_recorder_folder) + "/";
//        createFolder(RECORDER_FOLDER);
//
//        PIC_FOLDER = DEFAULT_FOLDER + context.getResources().getString(R.string.im_pic_folder) + "/";
//
//        createFolder(PIC_FOLDER);
//
//        ATTACH_FOLDER = DEFAULT_FOLDER + context.getResources().getString(R.string.im_attach_folder) + "/";
//        createFolder(ATTACH_FOLDER);
//
//        PHOTO_FOLDER = DEFAULT_FOLDER + context.getResources().getString(R.string.im_photo_folder) + "/";
//        createFolder(PHOTO_FOLDER);
//
//        RECORDER_VIDEO_FOLDER = DEFAULT_FOLDER + context.getResources().getString(R.string.im_recorder_video_folder) + "/";
//        createFolder(RECORDER_VIDEO_FOLDER);
//
//        IMAGE_FOLDER = DEFAULT_FOLDER + context.getResources().getString(R.string.im_tmp_image) + "/";
//        createFolder(IMAGE_FOLDER);
//
//        UPGRADE_FOLDER = DEFAULT_FOLDER + context.getResources().getString(R.string.im_upgrade_folder) + "/";
//        createFolder(UPGRADE_FOLDER);
    }

    private void createFolder(String path) {
        File file = new File(path);
        if (file.exists()) {
            if (file.isFile()) {
                file.delete();
                file.mkdir();
            }
        } else {
            file.mkdir();
        }
    }
}
